var form = layui.form,
    table = layui.table,
    $ = layui.jquery,
    drawbackId = getQueryVariable("drawbackId");

    var data0 = [{
        id: "1",
        contracttype: "text1",
        productimg: "statics/images/layui-logo.jpg",
        number: "3",
        batchno: "333",
        warehousename:"1",
        productcode:"1"
    }, {
        id: "2",
        contracttype: "text1",
        productimg: "statics/images/layui-logo.jpg",
        number: "3",
        batchno: "333",
        warehousename:"1",
        productcode:"2"
    }, {id: "3", contracttype: "text1", productimg: "statics/images/layui-logo.jpg", number: "3", batchno: "333",
        warehousename:"1",
        productcode:"3"}];
    var data1 = [{
        id: "1",
        filename: "layui-logo.jpg",
        url: "statics/images/layui-logo.jpg",
        uploaddate: "2020-10-01"
    }, {id: "2", filename: "layui-logo.jpg", url: "statics/images/layui-logo.jpg", uploaddate: "2020-10-01"}, {
        id: "3",
        filename: "layui-logo.jpg",
        url: "statics/images/layui-logo.jpg",
        uploaddate: "2020-10-01"
    }, {id: "4", filename: "layui-logo.jpg", url: "statics/images/layui-logo.jpg", uploaddate: "2020-10-01"}];
var data2 = [{
    id: "1",
    operationtype: "text1",
    theoperator: "text2",
    operationdate: "text3",
    modifythecontent: "text4"
}, {
    id: "2",
    operationtype: "text1",
    theoperator: "text2",
    operationdate: "text3",
    modifythecontent: "text4"
    }, {
        id: "3",
        operationtype: "text1",
        theoperator: "text2",
        operationdate: "text3",
        modifythecontent: "text4"
    }, {id: "4", operationtype: "text1", theoperator: "text2", operationdate: "text3", modifythecontent: "text4"}];
var data3 = [{id:"1","customscode":"text1",cuchinesename:"text2"},{id:"2","customscode":"text2",cuchinesename:"text2"},{id:"3","customscode":"text3",cuchinesename:"text2"},{id:"4","customscode":"text4",cuchinesename:"text2"},{id:"5","customscode":"text5",cuchinesename:"text2"}];

$('#editor-form').find('input,textarea,select').attr('disabled',true);
//表单初始值，修改时调用
if (drawbackId != "") {
    form.val("editor-form", {
        "invoicenumber": "进入查看明细",
    })
}
//附件信息
let annexData=[];
layer.ready(function () {
    $.ajax({
        url:"drawback/findDrawbackDetail",
        type:"POST",
        dataType:"json",
        contentType: 'application/json',
        data:JSON.stringify(drawbackId),
        success:function(res) {
            if (res.status == 200) {
                $("#drawbackId").val(res.data.drawbackId);
                $("#drawbackCode").val(res.data.drawbackCode);
                $("#shippingDate").val(res.data.shippingDate);
                $("#customerName").val(res.data.customerName);
                $("#businessMode").val(res.data.businessMode);
                $("#declarationDate").val(res.data.declarationDate);
                $("#invoiceCode").val(res.data.invoiceCode);
                $("#currencyName").val(res.data.currencyName);
                $("#rmbRate").val(res.data.rmbRate);
                $("#usdRate").val(res.data.usdRate);
                $("#declarationAmount").val(res.data.declarationAmount);
                $("#theoreticalTaxRefund").val(res.data.theoreticalTaxRefund);
                $("#contractCode").val(res.data.contractCode);
                $("#exporterName").val(res.data.exporterName);
                $("#operatorName").val(res.data.operatorName);
                $("#drawbackOperatorName").val(res.data.drawbackOperatorName);
                $("#drawbackOperatorCode").val(res.data.drawbackOperatorCode);
                $("#actualTaxRefund").val(res.data.actualTaxRefund);
                $("#registerDate").val(res.data.registerDate);
                $("#remarks").val(res.data.remarks);
                annexData=res.data.costAnnexVOList;
                table.reload('attachmenttableid',{data : annexData});
            }

        }
    });
});
//---附件
table.render({
    elem: '#attachment'
    , data: annexData
    , cols: [[
        {field: 'fileName', title: '文件名', fixed: true}
        , {field: 'uploadTime', title: '上传日期', fixed: true}
        , {fixed: 'right', width: 180, align: 'center', toolbar: '#attachmenteditor', title: '操作'}
    ]]
    , id: 'attachmenttableid'
    , height: 380
    , page: true
});

table.on('tool(attachmenttable)', function (obj) {
    var data = obj.data;
    if (obj.event === 'download') { //下载
        var a = document.createElement('a');
        var event = new MouseEvent('click');
        a.download = data.fileName;
        a.href = data.filePath;
        a.dispatchEvent(event)
    }
});

//---操作日志
    table.render({
        elem: '#otherwarehouselog'
        , data: data2
        , cols: [[
            {field: 'operationtype', title: '操作类型', fixed: true}
            , {field: 'theoperator', title: '操作员'}
            , {field: 'operationdate', title: '操作日期'}
            , {field: 'modifythecontent', title: '修改内容'}
        ]]
        , id: 'logtableid'
        , height: 380
        , limit: 30//显示的数量
        , page: true
    });